//
//  LBNotEnouchView.m
//  loveBeen
//
//  Created by guofei on 2016/11/24.
//  Copyright © 2016年 loveBeen. All rights reserved.
//

#import "LBNotEnouchView.h"

@implementation LBNotEnouchView

-(instancetype)initWithName:(NSString *)nameString {

    if (self = [super init]) {
        [self setupUIWithName:nameString];
    }
    return self;
}


- (void)setupUIWithName:(NSString *)nameString {
    
    self.backgroundColor = [UIColor cz_colorWithHex:0xe4e4e4];
    // 切圆角
    self.layer.cornerRadius = 12;
    self.layer.masksToBounds = YES;
    self.alpha = 0.9;
    
    // icon
    UIImageView *iconImg = [[UIImageView alloc]init];
    [self addSubview:iconImg];
    iconImg.image = [UIImage imageNamed:@"error"];
    
    // uplabel
    UILabel *nameLabel = [[UILabel alloc]init];
    [self addSubview:nameLabel];
    
    NSString *nameStr = [NSString stringWithFormat:@"%@ 库存不足了",nameString];
    nameLabel.text = nameStr;
    nameLabel.font = [UIFont systemFontOfSize:14];
    nameLabel.textColor = [UIColor cz_colorWithHex:0x202020];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.numberOfLines = 0;
    
    // seelabel
    UILabel *seeLabel = [[UILabel alloc]init];
    [self addSubview:seeLabel];
    
    NSString *seeStr = @"先买这么多, 过段时间再来看看吧~";
    seeLabel.text = seeStr;
    seeLabel.font = [UIFont systemFontOfSize:14];
    seeLabel.textColor = [UIColor cz_colorWithHex:0x202020];
    seeLabel.textAlignment = NSTextAlignmentCenter;
    seeLabel.numberOfLines = 0;
    
    // icon 的约束
    [iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(15);
        make.centerX.equalTo(self);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    // namelabel 约束
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(iconImg.mas_bottom).offset(10);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        
    }];
    
    [seeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom).offset(-10);
        make.left.offset(15);
        make.right.offset(-15);
        
    }];


};

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
